<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script type="text/javascript" src="./browserfs.min.js"></script>
    <script type="text/javascript">
      // Installs globals onto window:
      // * Buffer
      // * require (monkey-patches if already defined)
      // * process
      // You can pass in an arbitrary object if you do not wish to pollute
      // the global namespace.
      BrowserFS.install(window);
      // Configures BrowserFS to use the LocalStorage file system.
      BrowserFS.configure(
        {
          fs: "LocalStorage"
        },
        function(e) {
          if (e) {
            // An error happened!
            throw e;
          }
          // Otherwise, BrowserFS is ready-to-use!
        }
      );
    </script>
    <script>
      var fs = require('fs');
      fs.writeFile('/test.txt', 'Cool, I can do this in the browser!', function(err) {
        fs.readFile('/test.txt', function(err, contents) {
          console.log(contents.toString());
        });
      });
    </script>
  </body>
</html>
